<template>
    <table>
      <tr>
          <td>房型名称</td>
          <td>
              <input type="text" v-model="info.R_fangxin" placeholder="请输入房型名称">
          </td>
      </tr>
      <tr>
          <td>房号</td>
          <td>
              <input type="text" v-model="info.R_Name" placeholder="请输入房号">
          </td>
      </tr>
      <tr>
          <td>状态</td>
          <td>
              <input type="radio"  :value="true" v-model="info.R_Status">启用
              <input type="radio" :value="false" v-model="info.R_Status">禁用
          </td>
      </tr>
      <tr>
          <td>备注</td>
          <td>   
              <input type="text" v-model="info.R_BeiZhu" placeholder="请输入备注">
          </td>
      </tr>
      <tr>
          <td></td>
          <td>
              <input type="button" value="修改" @click="save" >
          </td>
      </tr>
    </table>
  </template>
  
  <script setup lang="ts">
  import {onMounted, ref} from 'vue'
  import axios from 'axios'
  import { useRoute,useRouter } from 'vue-router';
  
  
  const user=useRouter();
  const use=useRoute();
  
  const info=ref({
    "R_Id": 1,
  "R_fangxin": "",
  "R_Name": "",
  "R_Status": true,
  "R_BeiZhu": "",
  "R_Biblio": true
  
  })
  onMounted(()=>{
    fantian()
  })
  const fantian=()=>{
    axios.get("https://localhost:7285/api/Roomnumber/GetNumberByid",{
        params:{
            id:use.params.id
        }
    })
    .then(res=>{
        info.value=res.data
    })
  }
  const  save=()=>{
      axios.put("https://localhost:7285/api/Roomnumber/UpdaNumber",info.value)
      .then(res=>{
          if(res.data>0){
              alert("修改成功");
              user.push("/ShowNumber")
          }else{
              alert("修改成功");
          }
      })
  }
  </script>
  
  <style scoped>
  
  </style>